package com.fauks.ee.freemarker;

import java.io.IOException;
import java.io.InputStreamReader;
import java.nio.charset.StandardCharsets;
import java.util.Objects;
import java.util.Properties;

public class PropertiesUtils {

    private static Properties properties;

    public static void readPrperties(String fileName) throws IOException {
        properties = new Properties();
        InputStreamReader inputStreamReader = new InputStreamReader(Objects.requireNonNull(PropertiesUtils.class.getClassLoader().getResourceAsStream(fileName)), StandardCharsets.UTF_8);
        properties.load(inputStreamReader);
    }

    public static String get(String fileName, String key) {
        try {
            readPrperties(fileName);
            return properties.getProperty(key);
        } catch (IOException e) {
            e.printStackTrace();
        }
        return "";
    }
}
